{% extends "FOSUserBundle::layout.html.twig" %}

{% block fos_user_content %}

	<p class="text-right">
            <a class="action_connection" href="#"><button class="button small orange">Connexion</button></a>
	</p>
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
      		<div class="modal-content">
        		<div class="modal-header">
          			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          			<h4 class="modal-title">Connexion</h4>
        		</div>
        	<div class="modal-body">
				<form id="form_connection" action="{{ path("fos_user_security_check") }}" method="post" class="navbar-form form-horizontal" style="color:#999;">
					<p id="error_connection" class="text-danger">
					{% if error %}
			    		{{ error|trans({}, 'FOSUserBundle') }}
					{% endif %}
					</p>
					<input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />
					<div class="form-group">
					  	<label for="username" class="control-label col-lg-4">{{ 'security.login.username'|trans({}, 'FOSUserBundle') }}</label>
					  	<div class="col-lg-7">
					  		<input placeholed=""type="text" class="form-control" name="_username" id="username" value="{{ last_username }}" required="required" />
					  	</div>
					</div>
					<div class="form-group">
					  	<label for="password" class=" control-label col-lg-4">{{ 'security.login.password'|trans({}, 'FOSUserBundle') }}</label>
					  	<div class="col-lg-7">
							<input type="password" class="form-control" name="_password" id="password" required="required" />
							<div class="checkbox">
			        			<label><input type="checkbox" value="on" id="remember_me" name="_remember_me" style="width:inherit;"> {{ 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}</label>
			      			</div><br/>
			      			
				                <button type="submit" id="_submit" name="_submit" class="pull-right button small orange">{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}</button>
						</div>
					</div>
				</form>
			   </div>
    		</div>
		</div>
	</div>
	<script type="text/javascript">
	    $(document).ready(function(){
			$(".action_connection").on('click',function(){
	            $('#myModal').modal('show');
	            return false;
	        });

	        $("#form_connection").submit(function(event){
                event.preventDefault();
                $.ajax({
                    type: "POST",
                    url : $(this).attr("action"),
                    data: $(this).serialize(),
                    success: function(data){
                    	var result = jQuery.parseJSON(data);
                        if(result.success){
                        	$('#myModal').modal('hide');
                        	 $.ajax({
                    			type: "POST",
                    			url : "{{ path('nuit_info2013_main_connection') }}",
                    			success: function(data){
                        			$('#header-contact').html(data);
                        			$('.forumhome').toggle();
                        		}
                        	});
                        }
                        else
                        	$("#error_connection").html(result.result);
                    }
                });
            });
	    });
	</script>
{% endblock %}
        
 {% block body %}
 <div id="sheetContent" class="clear">
<!-- ################################################################################################ -->
<!--
        H O M E P A G E
    -->

    {{ render(controller("NuitInfo2013MainBundle:Main:homepage"))}}


    <!--
        G U I D E
    -->

    {{ render(controller("NuitInfo2013MainBundle:Guide:guide"))}}


    <!--
        F O R U M
    -->
    
    {{ render(controller('NuitInfo2013MainBundle:Forum:index')) }}
<!-- ################################################################################################ -->
</div>
<div class="clear"></div>
{% endblock %}

